#include "EventHandler.h"
#include "GL/glfw.h"

EventHandler::EventHandler(){
}

EventHandler::~EventHandler(){
}

void EventHandler::initialize(){
	isPressed['A'] = false;
	isPressed['B'] = false;
	isPressed['C'] = false;
	isPressed['D'] = false;
	isPressed['E'] = false;
	isPressed['F'] = false;
	isPressed['G'] = false;
	isPressed['H'] = false;
	isPressed['I'] = false;
	isPressed['J'] = false;
	isPressed['K'] = false;
	isPressed['L'] = false;
	isPressed['M'] = false;
	isPressed['N'] = false;
	isPressed['O'] = false;
	isPressed['P'] = false;
	isPressed['Q'] = false;
	isPressed['R'] = false;
	isPressed['S'] = false;
	isPressed['T'] = false;
	isPressed['U'] = false;
	isPressed['V'] = false;
	isPressed['W'] = false;
	isPressed['X'] = false;
	isPressed['Y'] = false;
	isPressed['Z'] = false;
	isPressed['0'] = false;
	isPressed['1'] = false;
	isPressed['2'] = false;
	isPressed['3'] = false;
	isPressed['4'] = false;
	isPressed['5'] = false;
	isPressed['6'] = false;
	isPressed['7'] = false;
	isPressed['8'] = false;
	isPressed['9'] = false;
	isPressed[GLFW_KEY_SPACE] = false;
	isPressed[GLFW_KEY_ESC] = false;
}

const EventType EventHandler::keyPressEvent(int c){
	if(glfwGetKey(c) == GLFW_PRESS){
		if(isPressed[c]){
			return KEY_HELD;
		} else {
			isPressed[c] = true;
			return KEY_PRESSED;
		}
	} else {
		if(isPressed[c]){
			isPressed[c] = false;
			return KEY_RELEASED;
		} else {
			return KEY_INACTIVE; 
		}
	}
}